package com.gzz.manage.sys.dept;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.gzz.common.aop.AutoLog;
import com.gzz.common.config.Result;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * @类说明 【组织机构】控制器
 * @author 高振中
 * @date 2020-11-15 21:39:55
 **/
//@Slf4j
@RestController
@RequestMapping("dept")
@Api(tags = "【组织机构】API")
public class DeptController {

	@Autowired
	private DeptService deptService; // 注入【组织机构】业务逻辑层

	@AutoLog("【组织机构】新增")
	@ApiOperation(value = "【组织机构】新增", notes = "【组织机构】新增")
	@PostMapping("save")
	public Result<Integer> save(@RequestBody @Validated Dept dept) {
		return Result.success(deptService.save(dept));
	}

	@AutoLog("【组织机构】删除")
	@ApiOperation(value = "【组织机构】删除", notes = "参数格式:[1,2,3,4...]")
	@PostMapping("delete")
	public Result<Integer> delete(@RequestBody Object[] ids) {
		return Result.success(deptService.delete(ids));
	}

	@AutoLog("【组织机构】修改")
	@ApiOperation(value = "【组织机构】修改", notes = "【组织机构】修改")
	@PostMapping("update")
	public Result<Integer> update(@RequestBody @Validated Dept dept) {
		return Result.success(deptService.update(dept));
	}
	@AutoLog("【组织机构】列表")
	@ApiOperation(value = "【组织机构】列表", notes = "【组织机构】列表")
	@PostMapping("list")
	public Result<List<Dept>> list(@RequestBody DeptCond cond) {
		return Result.success(deptService.list(cond));
	}
	@AutoLog("【组织机构】树")
	@ApiOperation(value = "【组织机构】树", notes = "【组织机构】树")
	@PostMapping("tree")
	public Result<List<Dept>> tree() {
		return Result.success(deptService.tree());
	}

}